<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// Route::middleware('auth:api')->get('/user', function (Request $request) {
//     return $request->user();
// });


//用户相关API
Route::prefix('admin')->group(function () {
    Route::get('/list', 'App\Http\Controllers\ums\AdminController@list');
    Route::post('/register', 'App\Http\Controllers\ums\AdminController@register');
    Route::post('/update', 'App\Http\Controllers\ums\AdminController@update');
    Route::post('/updateStatus', 'App\Http\Controllers\ums\AdminController@updateStatus');
    Route::post('/updatePwd', 'App\Http\Controllers\ums\AdminController@updatePwd');
    Route::get('/delete', 'App\Http\Controllers\ums\AdminController@delete');
    Route::get('/role', 'App\Http\Controllers\ums\AdminController@role');
    Route::post('/role/update', 'App\Http\Controllers\ums\AdminController@roleUpdate');
    Route::post('/login', 'App\Http\Controllers\ums\AdminController@login');
    Route::post('/delete', 'App\Http\Controllers\ums\AdminController@delete');
    Route::get('/info', 'App\Http\Controllers\ums\AdminController@info');
    
});
//角色相关API
Route::prefix('role')->group(function () {
    Route::get('/listAll', 'App\Http\Controllers\ums\RoleController@listAll');
    Route::get('/list', 'App\Http\Controllers\ums\RoleController@list');
    Route::get('/listMenu', 'App\Http\Controllers\ums\RoleController@listMenu');
    Route::post('/update', 'App\Http\Controllers\ums\RoleController@update');
    Route::post('/create', 'App\Http\Controllers\ums\RoleController@create');
    Route::get('/updateStatus', 'App\Http\Controllers\ums\RoleController@updateStatus');
    Route::post('/delete', 'App\Http\Controllers\ums\RoleController@delete');
    Route::post('/allocMenu', 'App\Http\Controllers\ums\RoleController@allocMenu');
});

//商户相关API
Route::prefix('merchant')->group(function () {
    //商户用户相关API
    Route::prefix('admin')->group(function () {
        Route::get('/list', 'App\Http\Controllers\merchant\AdminController@list');
        Route::post('/register', 'App\Http\Controllers\merchant\AdminController@register');
        Route::post('/update', 'App\Http\Controllers\merchant\AdminController@update');
        Route::post('/updateStatus', 'App\Http\Controllers\merchant\AdminController@updateStatus');
        Route::post('/updatePwd', 'App\Http\Controllers\merchant\AdminController@updatePwd');
        Route::get('/delete', 'App\Http\Controllers\merchant\AdminController@delete');
        Route::get('/role', 'App\Http\Controllers\merchant\AdminController@role');
        Route::post('/role/update', 'App\Http\Controllers\merchant\AdminController@roleUpdate');
        Route::post('/login', 'App\Http\Controllers\merchant\AdminController@login');
        Route::post('/delete', 'App\Http\Controllers\merchant\AdminController@delete');
        Route::get('/info', 'App\Http\Controllers\merchant\AdminController@info');
        
    });
    //商户角色相关API
    Route::prefix('role')->group(function () {
        Route::get('/listAll', 'App\Http\Controllers\merchant\RoleController@listAll');
        Route::get('/list', 'App\Http\Controllers\merchant\RoleController@list');
        Route::get('/listMenu', 'App\Http\Controllers\merchant\RoleController@listMenu');
        Route::post('/update', 'App\Http\Controllers\merchant\RoleController@update');
        Route::post('/create', 'App\Http\Controllers\merchant\RoleController@create');
        Route::get('/updateStatus', 'App\Http\Controllers\merchant\RoleController@updateStatus');
        Route::post('/delete', 'App\Http\Controllers\merchant\RoleController@delete');
        Route::post('/allocMenu', 'App\Http\Controllers\merchant\RoleController@allocMenu');
    });
});




// 大后台 - 机构管理API
Route::prefix('admin/merchants')->group(function () {
    Route::get('/', 'App\Http\Controllers\Admin\MerchantController@index');
    Route::post('/', 'App\Http\Controllers\Admin\MerchantController@store');
    
    Route::get('/menu-list', 'App\Http\Controllers\Admin\MerchantController@getMenuList');
    Route::get('/addresses', 'App\Http\Controllers\Admin\MerchantController@getAddresses');
    
    Route::get('/{id}', 'App\Http\Controllers\Admin\MerchantController@show');
    Route::put('/{id}', 'App\Http\Controllers\Admin\MerchantController@update');
    Route::delete('/{id}', 'App\Http\Controllers\Admin\MerchantController@destroy');
    Route::post('/{id}/admins', 'App\Http\Controllers\Admin\MerchantController@createAdmin');
    Route::post('/{id}/recharge', 'App\Http\Controllers\Admin\MerchantController@recharge');
    Route::get('/{id}/permissions', 'App\Http\Controllers\Admin\MerchantController@getPermissions');
    Route::post('/{id}/permissions', 'App\Http\Controllers\Admin\MerchantController@updatePermissions');
});

// 大后台 - 充值记录API
Route::get('admin/recharges', 'App\Http\Controllers\Admin\MerchantController@rechargeList');

// 大后台 - 商户管理员API
Route::get('admin/merchant-admins', 'App\Http\Controllers\Admin\MerchantController@adminList');
Route::post('admin/merchant-admins', 'App\Http\Controllers\Admin\MerchantController@createMerchantAdmin');
Route::put('admin/merchant-admins/{id}', 'App\Http\Controllers\Admin\MerchantController@updateMerchantAdmin');
Route::delete('admin/merchant-admins/{id}', 'App\Http\Controllers\Admin\MerchantController@deleteMerchantAdmin');
Route::post('admin/merchant-admins/{id}/status', 'App\Http\Controllers\Admin\MerchantController@updateMerchantAdminStatus');

// 商品分类相关API
Route::prefix('admin/goods')->group(function () {
    Route::post('/getCategories', 'App\Http\Controllers\goods\GoodsController@getCategories');
    Route::post('/createCategory', 'App\Http\Controllers\goods\GoodsController@createCategory');
    Route::post('/updateCategory', 'App\Http\Controllers\goods\GoodsController@updateCategory');
    Route::post('/deleteCategory', 'App\Http\Controllers\goods\GoodsController@deleteCategory');
    Route::post('/getCategory', 'App\Http\Controllers\goods\GoodsController@getCategory');
    Route::post('/getCategoriesWithChildren', 'App\Http\Controllers\goods\GoodsController@getCategoriesWithChildren');
});